


<!DOCTYPE html>
<html id="htmlId">
<head>
  <title>Coverage Report > LevelTest</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/highlight-idea.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.pack.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">nl.tudelft.jpacman.level</a>
</div>

<h1>Coverage Summary for Class: LevelTest (nl.tudelft.jpacman.level)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">LevelTest</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/10)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/36)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<pre>
<div class="sourceCode" id="sourceCode"><i class="no-highlight">1</i>&nbsp;package nl.tudelft.jpacman.level;
<i class="no-highlight">2</i>&nbsp;
<i class="no-highlight">3</i>&nbsp;import static org.assertj.core.api.Assertions.assertThat;
<i class="no-highlight">4</i>&nbsp;
<i class="no-highlight">5</i>&nbsp;import static org.mockito.Mockito.mock;
<i class="no-highlight">6</i>&nbsp;import static org.mockito.Mockito.times;
<i class="no-highlight">7</i>&nbsp;import static org.mockito.Mockito.verify;
<i class="no-highlight">8</i>&nbsp;import static org.mockito.Mockito.when;
<i class="no-highlight">9</i>&nbsp;import nl.tudelft.jpacman.board.Board;
<i class="no-highlight">10</i>&nbsp;import nl.tudelft.jpacman.board.Square;
<i class="no-highlight">11</i>&nbsp;import nl.tudelft.jpacman.npc.Ghost;
<i class="no-highlight">12</i>&nbsp;
<i class="no-highlight">13</i>&nbsp;import com.google.common.collect.Lists;
<i class="no-highlight">14</i>&nbsp;import org.junit.jupiter.api.BeforeEach;
<i class="no-highlight">15</i>&nbsp;import org.junit.jupiter.api.Test;
<i class="no-highlight">16</i>&nbsp;
<i class="no-highlight">17</i>&nbsp;/**
<i class="no-highlight">18</i>&nbsp; * Tests various aspects of level.
<i class="no-highlight">19</i>&nbsp; *
<i class="no-highlight">20</i>&nbsp; * @author Jeroen Roosen 
<i class="no-highlight">21</i>&nbsp; */
<i class="no-highlight">22</i>&nbsp;// The four suppress warnings ignore the same rule, which results in 4 same string literals
<i class="no-highlight">23</i>&nbsp;@SuppressWarnings({&quot;PMD.AvoidDuplicateLiterals&quot;, &quot;PMD.TooManyStaticImports&quot;})
<b class="nc"><i class="no-highlight">24</i>&nbsp;class LevelTest {</b>
<i class="no-highlight">25</i>&nbsp;
<i class="no-highlight">26</i>&nbsp;    /**
<i class="no-highlight">27</i>&nbsp;     * The level under test.
<i class="no-highlight">28</i>&nbsp;     */
<i class="no-highlight">29</i>&nbsp;    private Level level;
<i class="no-highlight">30</i>&nbsp;
<i class="no-highlight">31</i>&nbsp;    /**
<i class="no-highlight">32</i>&nbsp;     * An NPC on this level.
<i class="no-highlight">33</i>&nbsp;     */
<b class="nc"><i class="no-highlight">34</i>&nbsp;    private final Ghost ghost = mock(Ghost.class);</b>
<i class="no-highlight">35</i>&nbsp;
<i class="no-highlight">36</i>&nbsp;    /**
<i class="no-highlight">37</i>&nbsp;     * Starting position 1.
<i class="no-highlight">38</i>&nbsp;     */
<b class="nc"><i class="no-highlight">39</i>&nbsp;    private final Square square1 = mock(Square.class);</b>
<i class="no-highlight">40</i>&nbsp;
<i class="no-highlight">41</i>&nbsp;    /**
<i class="no-highlight">42</i>&nbsp;     * Starting position 2.
<i class="no-highlight">43</i>&nbsp;     */
<b class="nc"><i class="no-highlight">44</i>&nbsp;    private final Square square2 = mock(Square.class);</b>
<i class="no-highlight">45</i>&nbsp;
<i class="no-highlight">46</i>&nbsp;    /**
<i class="no-highlight">47</i>&nbsp;     * The board for this level.
<i class="no-highlight">48</i>&nbsp;     */
<b class="nc"><i class="no-highlight">49</i>&nbsp;    private final Board board = mock(Board.class);</b>
<i class="no-highlight">50</i>&nbsp;
<i class="no-highlight">51</i>&nbsp;    /**
<i class="no-highlight">52</i>&nbsp;     * The collision map.
<i class="no-highlight">53</i>&nbsp;     */
<b class="nc"><i class="no-highlight">54</i>&nbsp;    private final CollisionMap collisions = mock(CollisionMap.class);</b>
<i class="no-highlight">55</i>&nbsp;
<i class="no-highlight">56</i>&nbsp;    /**
<i class="no-highlight">57</i>&nbsp;     * Sets up the level with the default board, a single NPC and a starting
<i class="no-highlight">58</i>&nbsp;     * square.
<i class="no-highlight">59</i>&nbsp;     */
<i class="no-highlight">60</i>&nbsp;    @BeforeEach
<i class="no-highlight">61</i>&nbsp;    void setUp() {
<b class="nc"><i class="no-highlight">62</i>&nbsp;        final long defaultInterval = 100L;</b>
<b class="nc"><i class="no-highlight">63</i>&nbsp;        level = new Level(board, Lists.newArrayList(ghost), Lists.newArrayList(</b>
<i class="no-highlight">64</i>&nbsp;            square1, square2), collisions);
<b class="nc"><i class="no-highlight">65</i>&nbsp;        when(ghost.getInterval()).thenReturn(defaultInterval);</b>
<i class="no-highlight">66</i>&nbsp;    }
<i class="no-highlight">67</i>&nbsp;
<i class="no-highlight">68</i>&nbsp;    /**
<i class="no-highlight">69</i>&nbsp;     * Validates the state of the level when it isn&#39;t started yet.
<i class="no-highlight">70</i>&nbsp;     */
<i class="no-highlight">71</i>&nbsp;    @Test
<i class="no-highlight">72</i>&nbsp;    void noStart() {
<b class="nc"><i class="no-highlight">73</i>&nbsp;        assertThat(level.isInProgress()).isFalse();</b>
<i class="no-highlight">74</i>&nbsp;    }
<i class="no-highlight">75</i>&nbsp;
<i class="no-highlight">76</i>&nbsp;    /**
<i class="no-highlight">77</i>&nbsp;     * Validates the state of the level when it is stopped without starting.
<i class="no-highlight">78</i>&nbsp;     */
<i class="no-highlight">79</i>&nbsp;    @Test
<i class="no-highlight">80</i>&nbsp;    void stop() {
<b class="nc"><i class="no-highlight">81</i>&nbsp;        level.stop();</b>
<b class="nc"><i class="no-highlight">82</i>&nbsp;        assertThat(level.isInProgress()).isFalse();</b>
<i class="no-highlight">83</i>&nbsp;    }
<i class="no-highlight">84</i>&nbsp;
<i class="no-highlight">85</i>&nbsp;    /**
<i class="no-highlight">86</i>&nbsp;     * Validates the state of the level when it is started.
<i class="no-highlight">87</i>&nbsp;     */
<i class="no-highlight">88</i>&nbsp;    @Test
<i class="no-highlight">89</i>&nbsp;    void start() {
<b class="nc"><i class="no-highlight">90</i>&nbsp;        level.start();</b>
<b class="nc"><i class="no-highlight">91</i>&nbsp;        assertThat(level.isInProgress()).isTrue();</b>
<i class="no-highlight">92</i>&nbsp;    }
<i class="no-highlight">93</i>&nbsp;
<i class="no-highlight">94</i>&nbsp;    /**
<i class="no-highlight">95</i>&nbsp;     * Validates the state of the level when it is started then stopped.
<i class="no-highlight">96</i>&nbsp;     */
<i class="no-highlight">97</i>&nbsp;    @Test
<i class="no-highlight">98</i>&nbsp;    void startStop() {
<b class="nc"><i class="no-highlight">99</i>&nbsp;        level.start();</b>
<b class="nc"><i class="no-highlight">100</i>&nbsp;        level.stop();</b>
<b class="nc"><i class="no-highlight">101</i>&nbsp;        assertThat(level.isInProgress()).isFalse();</b>
<i class="no-highlight">102</i>&nbsp;    }
<i class="no-highlight">103</i>&nbsp;
<i class="no-highlight">104</i>&nbsp;    /**
<i class="no-highlight">105</i>&nbsp;     * Verifies registering a player puts the player on the correct starting
<i class="no-highlight">106</i>&nbsp;     * square.
<i class="no-highlight">107</i>&nbsp;     */
<i class="no-highlight">108</i>&nbsp;    @Test
<i class="no-highlight">109</i>&nbsp;    @SuppressWarnings(&quot;PMD.JUnitTestsShouldIncludeAssert&quot;)
<i class="no-highlight">110</i>&nbsp;    void registerPlayer() {
<b class="nc"><i class="no-highlight">111</i>&nbsp;        Player p = mock(Player.class);</b>
<b class="nc"><i class="no-highlight">112</i>&nbsp;        level.registerPlayer(p);</b>
<b class="nc"><i class="no-highlight">113</i>&nbsp;        verify(p).occupy(square1);</b>
<i class="no-highlight">114</i>&nbsp;    }
<i class="no-highlight">115</i>&nbsp;
<i class="no-highlight">116</i>&nbsp;    /**
<i class="no-highlight">117</i>&nbsp;     * Verifies registering a player twice does not do anything.
<i class="no-highlight">118</i>&nbsp;     */
<i class="no-highlight">119</i>&nbsp;    @Test
<i class="no-highlight">120</i>&nbsp;    @SuppressWarnings(&quot;PMD.JUnitTestsShouldIncludeAssert&quot;)
<i class="no-highlight">121</i>&nbsp;    void registerPlayerTwice() {
<b class="nc"><i class="no-highlight">122</i>&nbsp;        Player p = mock(Player.class);</b>
<b class="nc"><i class="no-highlight">123</i>&nbsp;        level.registerPlayer(p);</b>
<b class="nc"><i class="no-highlight">124</i>&nbsp;        level.registerPlayer(p);</b>
<b class="nc"><i class="no-highlight">125</i>&nbsp;        verify(p, times(1)).occupy(square1);</b>
<i class="no-highlight">126</i>&nbsp;    }
<i class="no-highlight">127</i>&nbsp;
<i class="no-highlight">128</i>&nbsp;    /**
<i class="no-highlight">129</i>&nbsp;     * Verifies registering a second player puts that player on the correct
<i class="no-highlight">130</i>&nbsp;     * starting square.
<i class="no-highlight">131</i>&nbsp;     */
<i class="no-highlight">132</i>&nbsp;    @Test
<i class="no-highlight">133</i>&nbsp;    @SuppressWarnings(&quot;PMD.JUnitTestsShouldIncludeAssert&quot;)
<i class="no-highlight">134</i>&nbsp;    void registerSecondPlayer() {
<b class="nc"><i class="no-highlight">135</i>&nbsp;        Player p1 = mock(Player.class);</b>
<b class="nc"><i class="no-highlight">136</i>&nbsp;        Player p2 = mock(Player.class);</b>
<b class="nc"><i class="no-highlight">137</i>&nbsp;        level.registerPlayer(p1);</b>
<b class="nc"><i class="no-highlight">138</i>&nbsp;        level.registerPlayer(p2);</b>
<b class="nc"><i class="no-highlight">139</i>&nbsp;        verify(p2).occupy(square2);</b>
<i class="no-highlight">140</i>&nbsp;    }
<i class="no-highlight">141</i>&nbsp;
<i class="no-highlight">142</i>&nbsp;    /**
<i class="no-highlight">143</i>&nbsp;     * Verifies registering a third player puts the player on the correct
<i class="no-highlight">144</i>&nbsp;     * starting square.
<i class="no-highlight">145</i>&nbsp;     */
<i class="no-highlight">146</i>&nbsp;    @Test
<i class="no-highlight">147</i>&nbsp;    @SuppressWarnings(&quot;PMD.JUnitTestsShouldIncludeAssert&quot;)
<i class="no-highlight">148</i>&nbsp;    void registerThirdPlayer() {
<b class="nc"><i class="no-highlight">149</i>&nbsp;        Player p1 = mock(Player.class);</b>
<b class="nc"><i class="no-highlight">150</i>&nbsp;        Player p2 = mock(Player.class);</b>
<b class="nc"><i class="no-highlight">151</i>&nbsp;        Player p3 = mock(Player.class);</b>
<b class="nc"><i class="no-highlight">152</i>&nbsp;        level.registerPlayer(p1);</b>
<b class="nc"><i class="no-highlight">153</i>&nbsp;        level.registerPlayer(p2);</b>
<b class="nc"><i class="no-highlight">154</i>&nbsp;        level.registerPlayer(p3);</b>
<b class="nc"><i class="no-highlight">155</i>&nbsp;        verify(p3).occupy(square1);</b>
<i class="no-highlight">156</i>&nbsp;    }
<i class="no-highlight">157</i>&nbsp;}
</div>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
        var codeBlock = document.getElementById('sourceCode');

        if (codeBlock) {
            hljs.highlightBlock(codeBlock);
        }
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2022-05-22 18:55</div>
</div>
</body>
</html>
